package com.nbicc.parent.serivce;

import com.github.pagehelper.PageHelper;
import com.nbicc.common.RequestPageObj;
import com.nbicc.common.utils.CamelUtils;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by li on 18/1/8.
 */
public class BaseService implements Serializable {

    public void setPageHelper(RequestPageObj requestPageObj , String tableAlias){
        if(requestPageObj.getPageNum() != null &&
                requestPageObj.getPageSize() != null){
            PageHelper.startPage(requestPageObj.getPageNum(), requestPageObj.getPageSize());
        }
//        PageHelper.orderBy("asset.create_time desc");
        if(!StringUtils.isEmpty(tableAlias) && !StringUtils.isEmpty(requestPageObj.getSort())){
            PageHelper.orderBy(tableAlias+"."+ CamelUtils.camelToUnderline(requestPageObj.getSort()));
        }
    }

}
